<% layout('/layouts/default.html', {title: '考核任务指标表-指标信息管理', libs: ['validate','fileupload']}){ %>
<div class="main-content">
    <div class="box box-main">
        <div class="box-header with-border">
            <div class="box-tools pull-right">
                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
            </div>
        </div>
        <#form:form id="inputForm" model="${dcSupExamSumQuotaInfo}" action="${ctx}/quota/dcSupExamSumQuotaInfo/saveQuotas" method="post" class="form-horizontal">
        <div class="box-body">
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required hide">*</span> ${text('考核年度')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:hidden path="isNewRecord"/>
                            <#form:hidden path="examId" />
                            <#form:hidden path="versionNumber" />
                            <#form:hidden path="remarks2" />
                            <#form:hidden path="remarks3" />
                            <#form:input path="examYear" class="form-control digits"  maxlength="4" readonly="true"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('指标类别')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:select path="quotaType" dictType="dc_quotaType" blankOption="true"  data-placeholder="请选择"  class="form-control required" defaultValue="11"  readonly="true"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('序号')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="sortNum" class="form-control digits required"  maxlength="4" placeholder="请输入数字"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('目标内容')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:textarea path="quotaContent" rows="4" maxlength="255" class="form-control required" placeholder="请输入目标内容：例 政务公开" />
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required hide">*</span> ${text('单位')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="quotaUnit" maxlength="255" class="form-control " placeholder="例:亿元、万元、个、条、家、项、户等;若无则不填"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('考核评分单位')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:treeselect  title="${text('考核评分单位')}"
                            path="unitCodes" labelValue="${officeName!}" labelPath="unitNames"
                            url="${ctx}/quota/dcSupExamSumQuotaInfo/selectOrgs" type="text"
                            class="required" isReturnValue="false" allowClear="true" canSelectRoot="true" canSelectParent="true"
                            returnFullName="false" checkbox="false" chkboxType="{'Y':'','N':''}"
                            placeholder="请选择考核评分单位"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('被考核单位')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
<!--                            <#form:textarea path="exameOrgName" rows="4" class="form-control required"   placeholder="请选择被考核单位" onclick="selectAssess()"/>-->
<!--                            <#form:hidden path="exameOrg"/>-->
                            <#form:treeselect  title="${text('被考核单位')}"
                            path="exameOrg" labelValue="${officeName!}" labelPath="exameOrgName"
                            url="${ctx}/quota/dcSupExamSumQuotaInfo/chooseOrgs?examId=${dcSupExamSumQuotaInfo.examId}" type="text"
                            class="required" isReturnValue="false" allowClear="true" canSelectRoot="true" canSelectParent="true"
                            returnFullName="false" checkbox="true" chkboxType="{'Y':'','N':''}"
                            placeholder="请选择被考核单位"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('权数')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="quotaWeight" class="form-control  required" placeholder="请输入数字" onblur="checkRange()"/>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required ">*</span> ${text('本年度目标')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="currentYaerGoal" maxlength="255" class="form-control required" placeholder="请输入本年度目标: 例 完成"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required hide">*</span> ${text('上一年度目标任务')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="lastYaerGoal" maxlength="255" class="form-control "  placeholder="例: 完成、量化任务数"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required hide">*</span> ${text('上一年度完成情况')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:input path="lastYearComplete" maxlength="255" class="form-control " placeholder="定性指标填写 完成 ；定量指标填写:量化任务数"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required">*</span> ${text('考核方式')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:select path="assessMethod" dictType="dc_exam_assessment" blankOption="true"  data-placeholder="请选择" class="form-control required" />
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="control-label col-sm-4" title="">
                            <span class="required">*</span> ${text('备注')}：<i class="fa icon-question hide"></i></label>
                        <div class="col-sm-8">
                            <#form:select path="remarks" dictType="dc_exam_remarks" blankOption="true"  data-placeholder="请选择" class="form-control required" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="box-footer">
            <div class="row">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('提 交')}</button>&nbsp;
                    <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
                </div>
            </div>
        </div>
    </#form:form>
</div>
</div>
<% } %>
<script>
    $("#inputForm").validate({
        submitHandler: function(form){
           var nums=  $('#sortNum').val();
           if (nums != null && Number(nums) < 1){
               js.showMessage("序号不能小于1");
               return;
           }
            var unitCodesCode =$("#unitCodesCode").val();
            var unitCodesName =$("#unitCodesName").val();
            var exameOrgCode =$("#exameOrgCode").val();
            if(unitCodesCode && exameOrgCode){
                var orgCodes =   exameOrgCode.split(",");
                for(var i=0;i<orgCodes.length;i++){
                    if(unitCodesCode == orgCodes[i]){
                        js.showMessage(unitCodesName+"不能同时作为被考核单位和评分单位");
                        return;
                    }
                }
            }
            js.ajaxSubmitForm($(form), function(data){
                js.showMessage(data.message);
                if(data.result == Global.TRUE){
                    js.closeCurrentTabPage(function(contentWindow){
                        contentWindow.page();
                        window.parent[2][0].reload($("#remarks2").val(),$("#remarks3").val());
                    });
                }
            }, "json");
        }
    });
    function selectSubmitted(){
        layer.open({
            type: 2,
            title: ['选择考核评分单位'],
            area: ['850px', '600px'],
            content: "${ctx}/notice/dcSupExamNotice/getSixTeenFiveOrg",
            success:function (layero,index){
                var iframe = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                iframe.child($("#noticeOrgs").val(),$("#noticeOrgNames").val());
            }
        });
    }
    function selectAssess(){
        layer.open({
            type: 2,
            title: ['选择被考核单位'],
            area: ['850px', '600px'],
            content: "${ctx}/notice/dcSupExamNotice/getSixTeenFiveOrg",
            success:function (layero,index){
                var iframe = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                iframe.child($("#exameOrg").val(),$("#exameOrgName").val());
            }
        });
    }

    function checkRange(){
        var quotaWeight=  $('#quotaWeight').val();
        if (parseFloat(quotaWeight||0) >= 100){
            js.showMessage("当前权数已超过100,可能会超出预期范围")
        }
    }
</script>